public class StopThread {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new MRunnable());
        thread.start();
        Thread.sleep(1000);
        thread.interrupt();
    }

    public static class MRunnable implements Runnable {
        private int i = 0;

        @Override
        public void run() {
            while (!Thread.currentThread().isInterrupted()) {
                System.out.println(++i);
            }
            System.out.println("停止");
        }
    }
}
